<!DOCTYPE html>
<html lang="en" class="js csstransforms3d">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <meta name="generator" content="Hugo 0.20.7" />
    <meta name="description" content="">


    <link rel="shortcut icon" href="http://shardingjdbc.io/document/legacy/2.x/en/img/favicon.png" type="image/x-icon" />

    
    <title>Configuration</title>
    <link href="http://ovfotjrsi.bkt.clouddn.com/docs/css/nucleus.css" rel="stylesheet">
    <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link href="http://ovfotjrsi.bkt.clouddn.com/docs/css/theme.css" rel="stylesheet">
    <link href="http://ovfotjrsi.bkt.clouddn.com/docs/css/hugo-theme.css" rel="stylesheet">
    <script src="https://cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>
    <style type="text/css">:root #header + #content > #left > #rlblock_left
    {display:none !important;}</style>
    <link rel="stylesheet" href="http://cdn.bootcss.com/highlight.js/9.8.0/styles/monokai-sublime.min.css">
<link rel="stylesheet" href="http://ovfotjrsi.bkt.clouddn.com/docs/css/style.css">
  </head>
  <body class="" data-url="/02-guide/configuration/">
    
    <nav id="sidebar">
  <div id="header-wrapper">
    <div id="header">
      <img src="http://ovfotjrsi.bkt.clouddn.com/docs/img/sharding-jdbc.png" />
    </div>
</div>
  <div class="highlightable">
    <ul class="topics">
      
        
        
          
          
            
          
        
          
          
            
          
        
          
          
            
          
        
          
          
            
          
        
        
        
          
        
          
        
          
        
          
        
      
      
      
      

      
      
      
        
          
          
            
          
        
      
      
      

      <li class="dd-item  " data-nav-id="/00-overview/">
        <a href="http://shardingjdbc.io/document/legacy/2.x/en/00-overview/">
          <span>
            
              <b>0. </b>
            
             Overview
            
           </span>
        </a>
        
        <ul>
          
            <li class="dd-item " data-nav-id="/00-overview/intro/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/00-overview/intro/">
                <span>Brief Introduction     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/00-overview/news/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/00-overview/news/">
                <span>News     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/00-overview/contribution/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/00-overview/contribution/">
                <span>Contribute Code     </i></span>
              </a>
            </li>
          
        </ul>
        
      </li>
      
      
      

      
      
      
        
          
          
            
          
        
      
      
      

      <li class="dd-item  " data-nav-id="/01-start/">
        <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/">
          <span>
            
              <b>1. </b>
            
             Introduction
            
           </span>
        </a>
        
        <ul>
          
            <li class="dd-item " data-nav-id="/01-start/quick-start/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/quick-start/">
                <span>Quick Start     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/code-demo/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/code-demo/">
                <span>Usage Example     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/faq/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/faq/">
                <span>FAQ     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/features/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/features/">
                <span>Feature List     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/limitations/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/limitations/">
                <span>Use Limits     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/sql-supported/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/sql-supported/">
                <span>The list of available SQL syntax     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/01-start/stress-test/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/01-start/stress-test/">
                <span>The performance-test report     </i></span>
              </a>
            </li>
          
        </ul>
        
      </li>
      
      
      

      
      
      
        
          
          
            
          
        
      
      
      

      <li class="dd-item  parent" data-nav-id="/02-guide/">
        <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/">
          <span>
            
              <b>2. </b>
            
             User Manual
            
           </span>
        </a>
        
        <ul>
          
            <li class="dd-item " data-nav-id="/02-guide/concepts/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/concepts/">
                <span>Basic Concepts      </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/sharding/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/sharding/">
                <span>Sharding     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/master-slave/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/master-slave/">
                <span>Read-write splitting     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/config_domain/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/config_domain/">
                <span>Domain Model Configuration     </i></span>
              </a>
            </li>
          
            <li class="dd-item active" data-nav-id="/02-guide/configuration/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/configuration/">
                <span>Configuration     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/orchestration/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/orchestration/">
                <span>Orchestration     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/hint-sharding-value/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/hint-sharding-value/">
                <span>Mandatory Routing     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/key-generator/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/key-generator/">
                <span>Distributed Primary key     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/transaction/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/transaction/">
                <span>Transaction Support     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/subquery/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/subquery/">
                <span>The Pagination and subquery     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/test-framework/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/test-framework/">
                <span>Test Engine     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/apm/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/apm/">
                <span>APM     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/02-guide/sharding-jdbc-server/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/sharding-jdbc-server/">
                <span>Sharding-JDBC-Server     </i></span>
              </a>
            </li>
          
        </ul>
        
      </li>
      
      
      

      
      
      
        
          
          
            
          
        
      
      
      

      <li class="dd-item  " data-nav-id="/03-design/">
        <a href="http://shardingjdbc.io/document/legacy/2.x/en/03-design/">
          <span>
            
              <b>3. </b>
            
             Design Plan
            
           </span>
        </a>
        
        <ul>
          
            <li class="dd-item " data-nav-id="/03-design/architecture/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/03-design/architecture/">
                <span>Architecture Design     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/03-design/module/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/03-design/module/">
                <span>Module Declaration     </i></span>
              </a>
            </li>
          
            <li class="dd-item " data-nav-id="/03-design/roadmap/">
              <a href="http://shardingjdbc.io/document/legacy/2.x/en/03-design/roadmap/">
                <span>Roadmap     </i></span>
              </a>
            </li>
          
        </ul>
        
      </li>
      
      
    </ul>
    <hr>
     
  </div>
</nav>

        <section id="body">
        <div id="overlay"></div>

        <div class="padding highlightable">

            <div id="top-bar">
              
              <div id="breadcrumbs" itemscope="" itemtype="http://data-vocabulary.org/Breadcrumb">
                  <span id="sidebar-toggle-span">
                      <a href="#" id="sidebar-toggle" data-sidebar-toggle="">
                        <i class="fa fa-bars"></i>
                      </a>
                  </span>
                
                <span id="toc-menu"><a href=""><i class="fa fa-list-alt"></i></a></span>
                
                
                  
                  
                  
                    
                    
                <a href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/" itemprop="url"><span itemprop="title">User Manual</span></a> <i class="fa fa-angle-right"></i>
                    
                  
                
                <span itemprop="title"> Configuration</span>
              </div>
              
                  <div class="progress">
    <div class="wrapper">
<nav id="TableOfContents">
<ul>
<li>
<ul>
<li><a href="#1-java-configuration">1.JAVA Configuration</a>
<ul>
<li><a href="#import-the-dependency-of-maven">Import the dependency of maven</a></li>
<li><a href="#configuration-example">Configuration Example</a>
<ul>
<li><a href="#sharding-configuration">Sharding Configuration</a></li>
<li><a href="#read-write-splitting-configuration">Read-write splitting Configuration</a></li>
</ul></li>
</ul></li>
<li><a href="#2-yaml-configuration">2.YAML Configuration</a>
<ul>
<li><a href="#import-the-dependency-of-maven-1">Import the dependency of maven</a></li>
<li><a href="#configuration-example-1">Configuration Example</a>
<ul>
<li><a href="#sharding-configuration-1">Sharding Configuration</a></li>
<li><a href="#the-config-items-for-sharding">The config items for Sharding</a></li>
<li><a href="#the-construction-method-for-data-source-of-sharding">The construction method for data source of Sharding</a></li>
<li><a href="#read-write-splitting-configuration-1">Read-write splitting Configuration</a></li>
<li><a href="#the-config-items-for-read-write-splitting">The config items for Read-write splitting</a></li>
<li><a href="#the-construction-method-for-data-source-of-read-write-splitting">The construction method for data source of Read-write splitting</a></li>
</ul></li>
<li><a href="#more-detail-on-yaml-configuration">More detail on YAML Configuration</a></li>
</ul></li>
<li><a href="#3-the-configuration-for-spring-namespace">3. The Configuration for Spring namespace</a>
<ul>
<li><a href="#import-the-dependency-of-maven-2">Import the dependency of maven</a></li>
<li><a href="#configuration-example-2">Configuration Example</a></li>
<li><a href="#introduction-for-labels">Introduction for labels</a>
<ul>
<li><a href="#sharding-data-source">&lt;sharding:data-source/&gt;</a></li>
<li><a href="#sharding-sharding-rule">&lt;sharding:sharding-rule/&gt;</a></li>
<li><a href="#sharding-table-rules">&lt;sharding:table-rules/&gt;</a></li>
<li><a href="#sharding-table-rule">&lt;sharding:table-rule/&gt;</a></li>
<li><a href="#sharding-binding-table-rules">&lt;sharding:binding-table-rules/&gt;</a></li>
<li><a href="#sharding-binding-table-rule">&lt;sharding:binding-table-rule/&gt;</a></li>
<li><a href="#sharding-standard-strategy">&lt;sharding:standard-strategy/&gt;</a></li>
<li><a href="#sharding-complex-strategy">&lt;sharding:complex-strategy/&gt;</a></li>
<li><a href="#sharding-inline-strategy">&lt;sharding:inline-strategy/&gt;</a></li>
<li><a href="#sharding-hint-database-strategy">&lt;sharding:hint-database-strategy/&gt;</a></li>
<li><a href="#sharding-none-strategy">&lt;sharding:none-strategy/&gt;</a></li>
<li><a href="#sharding-props">&lt;sharding:props/&gt;</a></li>
<li><a href="#master-slave-data-source">&lt;master-slave:data-source/&gt;</a></li>
<li><a href="#more-details-on-spring-configuration">More details on Spring Configuration</a></li>
</ul></li>
</ul></li>
<li><a href="#the-description-of-sharding-algorithm-expression-syntax">The description of sharding algorithm expression syntax</a>
<ul>
<li><a href="#the-details-on-inline-expression">The details on inline expression</a></li>
<li><a href="#the-groovy-code-in-strings">The groovy code in strings</a></li>
</ul></li>
<li><a href="#4-spring-boot-configuration">4.Spring Boot Configuration</a>
<ul>
<li><a href="#import-the-dependency-of-maven-3">Import the dependency of maven</a></li>
<li><a href="#configuration-example-3">Configuration Example</a>
<ul>
<li><a href="#sharding-configuration-2">Sharding Configuration</a></li>
<li><a href="#the-details-on-some-config-options-for-sharding">The details on some Config options for Sharding</a></li>
<li><a href="#read-write-splitting-configuration-2">Read-write splitting Configuration</a></li>
<li><a href="#the-details-on-some-config-options-for-reading-writing-splitting">The details on some Config options for Reading-writing splitting</a></li>
</ul></li>
</ul></li>
</ul></li>
</ul>
</nav>
    </div>
</div>

              

            </div>
            
              <div id="body-inner">
                
                <h1>Configuration</h1>
                



<h2 id="1-java-configuration">1.JAVA Configuration</h2>

<h3 id="import-the-dependency-of-maven">Import the dependency of maven</h3>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;io.shardingjdbc&lt;/groupId&gt;
    &lt;artifactId&gt;sharding-jdbc-core&lt;/artifactId&gt;
    &lt;version&gt;${latest.release.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<h3 id="configuration-example">Configuration Example</h3>

<h4 id="sharding-configuration">Sharding Configuration</h4>

<pre><code class="language-java">     DataSource getShardingDataSource() throws SQLException {
         ShardingRuleConfiguration shardingRuleConfig = new ShardingRuleConfiguration();
         shardingRuleConfig.getTableRuleConfigs().add(getOrderTableRuleConfiguration());
         shardingRuleConfig.getTableRuleConfigs().add(getOrderItemTableRuleConfiguration());
         shardingRuleConfig.getBindingTableGroups().add(&quot;t_order, t_order_item&quot;);
         shardingRuleConfig.setDefaultDatabaseShardingStrategyConfig(new InlineShardingStrategyConfiguration(&quot;user_id&quot;, &quot;demo_ds_${user_id % 2}&quot;));
         shardingRuleConfig.setDefaultTableShardingStrategyConfig(new StandardShardingStrategyConfiguration(&quot;order_id&quot;, ModuloShardingTableAlgorithm.class.getName()));
         return ShardingDataSourceFactory.createDataSource(createDataSourceMap(), shardingRuleConfig);
     }
     
     TableRuleConfiguration getOrderTableRuleConfiguration() {
         TableRuleConfiguration orderTableRuleConfig = new TableRuleConfiguration();
         orderTableRuleConfig.setLogicTable(&quot;t_order&quot;);
         orderTableRuleConfig.setActualDataNodes(&quot;demo_ds_${0..1}.t_order_${0..1}&quot;);
         orderTableRuleConfig.setKeyGeneratorColumnName(&quot;order_id&quot;);
         return orderTableRuleConfig;
     }
     
     TableRuleConfiguration getOrderItemTableRuleConfiguration() {
         TableRuleConfiguration orderItemTableRuleConfig = new TableRuleConfiguration();
         orderItemTableRuleConfig.setLogicTable(&quot;t_order_item&quot;);
         orderItemTableRuleConfig.setActualDataNodes(&quot;demo_ds_${0..1}.t_order_item_${0..1}&quot;);
         return orderItemTableRuleConfig;
     }
     
     Map&lt;String, DataSource&gt; createDataSourceMap() {
         Map&lt;String, DataSource&gt; result = new HashMap&lt;&gt;(2, 1);
         result.put(&quot;demo_ds_0&quot;, DataSourceUtil.createDataSource(&quot;demo_ds_0&quot;));
         result.put(&quot;demo_ds_1&quot;, DataSourceUtil.createDataSource(&quot;demo_ds_1&quot;));
         return result;
     }
</code></pre>

<h4 id="read-write-splitting-configuration">Read-write splitting Configuration</h4>

<pre><code class="language-java">     DataSource getMasterSlaveDataSource() throws SQLException {
         MasterSlaveRuleConfiguration masterSlaveRuleConfig = new MasterSlaveRuleConfiguration();
         masterSlaveRuleConfig.setName(&quot;demo_ds_master_slave&quot;);
         masterSlaveRuleConfig.setMasterDataSourceName(&quot;demo_ds_master&quot;);
         masterSlaveRuleConfig.setSlaveDataSourceNames(Arrays.asList(&quot;demo_ds_slave_0&quot;, &quot;demo_ds_slave_1&quot;));
         return MasterSlaveDataSourceFactory.createDataSource(createDataSourceMap(), masterSlaveRuleConfig);
     }
     
     Map&lt;String, DataSource&gt; createDataSourceMap() {
         final Map&lt;String, DataSource&gt; result = new HashMap&lt;&gt;(3, 1);
         result.put(&quot;demo_ds_master&quot;, DataSourceUtil.createDataSource(&quot;demo_ds_master&quot;));
         result.put(&quot;demo_ds_slave_0&quot;, DataSourceUtil.createDataSource(&quot;demo_ds_slave_0&quot;));
         result.put(&quot;demo_ds_slave_1&quot;, DataSourceUtil.createDataSource(&quot;demo_ds_slave_1&quot;));
         return result;
     }
</code></pre>

<h2 id="2-yaml-configuration">2.YAML Configuration</h2>

<h3 id="import-the-dependency-of-maven-1">Import the dependency of maven</h3>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;io.shardingjdbc&lt;/groupId&gt;
    &lt;artifactId&gt;sharding-jdbc-core&lt;/artifactId&gt;
    &lt;version&gt;${latest.release.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<h3 id="configuration-example-1">Configuration Example</h3>

<h4 id="sharding-configuration-1">Sharding Configuration</h4>

<pre><code class="language-yaml">dataSources:
  db0: !!org.apache.commons.dbcp.BasicDataSource
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:db0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
    username: sa
    password: 
    maxActive: 100
  db1: !!org.apache.commons.dbcp.BasicDataSource
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
    username: sa
    password: 
    maxActive: 100

shardingRule:
  tables:
    config:
      actualDataNodes: db${0..1}.t_config
    t_order: 
      actualDataNodes: db${0..1}.t_order_${0..1}
      databaseStrategy: 
        standard:
          shardingColumn: user_id
          preciseAlgorithmClassName: io.shardingjdbc.core.yaml.fixture.SingleAlgorithm
      tableStrategy: 
        inline:
          shardingColumn: order_id
          algorithmInlineExpression: t_order_${order_id % 2}
      keyGeneratorColumnName: order_id
      keyGeneratorClass: io.shardingjdbc.core.yaml.fixture.IncrementKeyGenerator
    t_order_item:
      actualDataNodes: db${0..1}.t_order_item_${0..1}
      databaseStrategy: 
        standard:
          shardingColumn: user_id
          preciseAlgorithmClassName: io.shardingjdbc.core.yaml.fixture.SingleAlgorithm
      tableStrategy: 
        inline:
          shardingColumn: order_id
          algorithmInlineExpression: t_order_item_${order_id % 2}
  # t_order and t_order are all bindingTables of each other because of their same sharding strategies.
  bindingTables:
    - t_order,t_order
  # The default sharding strategy
  defaultDatabaseStrategy:
    none:
  defaultTableStrategy:
    complex:
      shardingColumns: id, order_id
      algorithmClassName: io.shardingjdbc.core.yaml.fixture.MultiAlgorithm
  props:
    sql.show: true
</code></pre>

<h4 id="the-config-items-for-sharding">The config items for Sharding</h4>

<pre><code class="language-yaml">dataSources: # Config for data source
  &lt;data_source_name&gt; # Config for DB connection pool class. One or many configs are ok.
    driverClassName: # Class name for database driver.
    url: # The url for database connection.
    username: # Username used to access DB.
    password: # Password used to access DB.
    ... # Other configs for connection pool.

defaultDataSourceName: # Default datasource. Notice: Tables without sharding rules are accessed by using the default data source.

tables: # The config for sharding, One or many configs for logic_table_name are ok.
    &lt;logic_table_name&gt;: # Table name for LogicTables
        actualDataNodes: # Actual data nodes configured in the format of *datasource_name.table_name*, multiple configs spliced with commas, supporting the inline expression. The default value is composed of configured datasources and logic table. This default config is to generate broadcast table (*The same table existed in every DB for cascade query*) or to split databases without spliting tables.
        databaseStrategy: # Strategy for sharding databases, only one strategy can be chosen from following strategies:
            standard: # Standard sharding strategy for single sharding column.
                shardingColumn: # Sharding Column
                preciseAlgorithmClassName: # The class name for precise-sharding-algorithm used for = and IN. The default constructor or on-parametric constructor is needed.
                rangeAlgorithmClassName: # (Optional) The class name for range-sharding-algorithm used for BETWEEN. The default constructor or on-parametric constructor is needed.
            complex: # Complex sharding strategy for multiple sharding columns.
                shardingColumns : # Sharding Column, multiple sharding columns spliced with commas. 
                algorithmClassName: # The class name for sharding-algorithm. The default constructor or on-parametric constructor is needed.
            inline: inline # Inline sharding strategy.
                shardingColumn : # Sharding Column
                algorithmInlineExpression: #  The inline expression conformed to groovy dynamic syntax for sharding. 
            hint: # Hint sharding strategy
                algorithmClassName: # The class name for sharding-algorithm. The default constructor or on-parametric constructor is needed.
            none: # No sharding
        tableStrategy: # Strategy for sharding tables. The details is same as Strategy for sharding databases.
  bindingTables: # Config for Blinding tables
  - A list of logic_table_name, multiple logic_table_names spliced with commas.
  
defaultDatabaseStrategy: # Default strategy for sharding databases. The details is same as databaseStrategy.
 
defaultTableStrategy: # Default strategy for sharding databases. The details is same as tableStrategy.

props: Property Configuration (Optional)
    sql.show: # To show SQL or not. Default: false
    executor.size: # The number of running thread. Default: The number of CPU cores.
</code></pre>

<h4 id="the-construction-method-for-data-source-of-sharding">The construction method for data source of Sharding</h4>

<pre><code class="language-java">    DataSource dataSource = ShardingDataSourceFactory.createDataSource(yamlFile);
</code></pre>

<h4 id="read-write-splitting-configuration-1">Read-write splitting Configuration</h4>

<pre><code class="language-yaml">dataSources:
  db_master: !!org.apache.commons.dbcp.BasicDataSource
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:db_master;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
    username: sa
    password: 
    maxActive: 100
  db_slave_0: !!org.apache.commons.dbcp.BasicDataSource
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:db_slave_0;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
    username: sa
    password: 
    maxActive: 100
  db_slave_1: !!org.apache.commons.dbcp.BasicDataSource
    driverClassName: org.h2.Driver
    url: jdbc:h2:mem:db_slave_1;DB_CLOSE_DELAY=-1;DATABASE_TO_UPPER=false;MODE=MYSQL
    username: sa
    password: 
    maxActive: 100

masterSlaveRule:
  name: db_ms

  masterDataSourceName: db_master

  slaveDataSourceNames: [db_slave_0, db_slave_1]
</code></pre>

<h4 id="the-config-items-for-read-write-splitting">The config items for Read-write splitting</h4>

<pre><code class="language-yaml">dataSource: # Config for data sourc same as previous dataSource.

name: # Data source name for sharding.

masterDataSourceName: Datasource name for Master datasource

slaveDataSourceNames：Datasource name for Slave datasource, multiple datasource put in an Array.
</code></pre>

<h4 id="the-construction-method-for-data-source-of-read-write-splitting">The construction method for data source of Read-write splitting</h4>

<pre><code class="language-java">    DataSource dataSource = MasterSlaveDataSourceFactory.createDataSource(yamlFile);
</code></pre>

<h3 id="more-detail-on-yaml-configuration">More detail on YAML Configuration</h3>

<p>!! :implementation class.</p>

<p>[] :multiple items.</p>

<h2 id="3-the-configuration-for-spring-namespace">3. The Configuration for Spring namespace</h2>

<h3 id="import-the-dependency-of-maven-2">Import the dependency of maven</h3>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;io.shardingjdbc&lt;/groupId&gt;
    &lt;artifactId&gt;sharding-jdbc-core-spring-namespace&lt;/artifactId&gt;
    &lt;version&gt;${latest.release.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<h3 id="configuration-example-2">Configuration Example</h3>

<pre><code class="language-xml">&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;
&lt;beans xmlns=&quot;http://www.springframework.org/schema/beans&quot;
    xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot; 
    xmlns:context=&quot;http://www.springframework.org/schema/context&quot;
    xmlns:sharding=&quot;http://shardingjdbc.io/schema/shardingjdbc/sharding&quot; 
    xsi:schemaLocation=&quot;http://www.springframework.org/schema/beans 
                        http://www.springframework.org/schema/beans/spring-beans.xsd
                        http://www.springframework.org/schema/context 
                        http://www.springframework.org/schema/context/spring-context.xsd 
                        http://shardingjdbc.io/schema/shardingjdbc/sharding 
                        http://shardingjdbc.io/schema/shardingjdbc/sharding/sharding.xsd 
                        &quot;&gt;
    &lt;context:property-placeholder location=&quot;classpath:conf/rdb/conf.properties&quot; ignore-unresolvable=&quot;true&quot; /&gt;
    
    &lt;bean id=&quot;dbtbl_0&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
        &lt;property name=&quot;driverClassName&quot; value=&quot;com.mysql.jdbc.Driver&quot; /&gt;
        &lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/dbtbl_0&quot; /&gt;
        &lt;property name=&quot;username&quot; value=&quot;root&quot; /&gt;
        &lt;property name=&quot;password&quot; value=&quot;&quot; /&gt;
    &lt;/bean&gt;
    
    &lt;bean id=&quot;dbtbl_1&quot; class=&quot;org.apache.commons.dbcp.BasicDataSource&quot; destroy-method=&quot;close&quot;&gt;
        &lt;property name=&quot;driverClassName&quot; value=&quot;com.mysql.jdbc.Driver&quot; /&gt;
        &lt;property name=&quot;url&quot; value=&quot;jdbc:mysql://localhost:3306/dbtbl_1&quot; /&gt;
        &lt;property name=&quot;username&quot; value=&quot;root&quot; /&gt;
        &lt;property name=&quot;password&quot; value=&quot;&quot; /&gt;
    &lt;/bean&gt;
    
    &lt;sharding:standard-strategy id=&quot;databaseStrategy&quot; sharding-column=&quot;user_id&quot; precise-algorithm-class=&quot;io.shardingjdbc.spring.algorithm.PreciseModuloDatabaseShardingAlgorithm&quot; /&gt;
    &lt;sharding:standard-strategy id=&quot;tableStrategy&quot; sharding-column=&quot;order_id&quot; precise-algorithm-class=&quot;io.shardingjdbc.spring.algorithm.PreciseModuloTableShardingAlgorithm&quot; /&gt;
    
    &lt;sharding:data-source id=&quot;shardingDataSource&quot;&gt;
        &lt;sharding:sharding-rule data-source-names=&quot;dbtbl_0,dbtbl_1&quot; default-data-source-name=&quot;dbtbl_0&quot;&gt;
            &lt;sharding:table-rules&gt;
                &lt;sharding:table-rule logic-table=&quot;t_order&quot; actual-data-nodes=&quot;dbtbl_${0..1}.t_order_${0..3}&quot; database-strategy-ref=&quot;databaseStrategy&quot; table-strategy-ref=&quot;tableStrategy&quot; /&gt;
                &lt;sharding:table-rule logic-table=&quot;t_order_item&quot; actual-data-nodes=&quot;dbtbl_${0..1}.t_order_item_${0..3}&quot; database-strategy-ref=&quot;databaseStrategy&quot; table-strategy-ref=&quot;tableStrategy&quot; /&gt;
            &lt;/sharding:table-rules&gt;
            &lt;sharding:binding-table-rules&gt;
                &lt;sharding:binding-table-rule logic-tables=&quot;t_order, t_order_item&quot; /&gt;
            &lt;/sharding:binding-table-rules&gt;
        &lt;/sharding:sharding-rule&gt;
        &lt;sharding:props&gt;
            &lt;prop key=&quot;sql.show&quot;&gt;true&lt;/prop&gt;
        &lt;/sharding:props&gt;
    &lt;/sharding:data-source&gt;
&lt;/beans&gt;
</code></pre>

<h3 id="introduction-for-labels">Introduction for labels</h3>

<h4 id="sharding-data-source">&lt;sharding:data-source/&gt;</h4>

<p>To define the data source for sharding-jdbc</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>id</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>Spring Bean ID</td>
</tr>

<tr>
<td>sharding-rule</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>Sharding Rule</td>
</tr>

<tr>
<td>binding-table-rules?</td>
<td>Label</td>
<td>-</td>
<td>N</td>
<td>Blinding Rule</td>
</tr>

<tr>
<td>props?</td>
<td>Label</td>
<td>-</td>
<td>N</td>
<td>Property Config</td>
</tr>
</tbody>
</table>

<h4 id="sharding-sharding-rule">&lt;sharding:sharding-rule/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>data-source-names</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The bean list of data sources, all the BEAN IDs of data sources (including the default data source) needed to be managed by Sharding-JDBC must be configured. Multiple bean IDs are separated by commas.</td>
</tr>

<tr>
<td>default-data-source-name</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The default name for data source. Tables without sharding rules will be considered in this data source.</td>
</tr>

<tr>
<td>default-database-strategy-ref</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The default strategy for sharding databases, which is also the strategy ID in &lt;sharding:xxx-strategy&gt;. If this property is not set, the strategy of none sharding will be applied.</td>
</tr>

<tr>
<td>default-table-strategy-ref</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The default strategy for sharding tables which is also the strategy ID in &lt;sharding:xxx-strategy&gt;. If this property is not set, the strategy of none sharding will be applied.</td>
</tr>

<tr>
<td>table-rules</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>The list of sharding rules.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-table-rules">&lt;sharding:table-rules/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>table-rule+</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>sharding rules</td>
</tr>
</tbody>
</table>

<h4 id="sharding-table-rule">&lt;sharding:table-rule/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>logic-table</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>LogicTables</td>
</tr>

<tr>
<td>actual-data-nodes</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>Actual data nodes configured in the format of <em>datasource_name.table_name</em>, multiple configs separated with commas, supporting the inline expression. The default value is composed of configured data sources and logic table. This default config is to generate broadcast table (<em>The same table existed in every DB for cascade query.</em>) or to split the database without splitting the table.</td>
</tr>

<tr>
<td>database-strategy-ref</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The strategy for sharding database.Its strategy ID is in &lt;sharding:xxx-strategy&gt;. The default is default-database-strategy-ref configured in &lt;sharding:sharding-rule/&gt;</td>
</tr>

<tr>
<td>table-strategy-ref</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The strategy for sharding table. Its strategy ID is in &lt;sharding:xxx-strategy&gt;. The default is default-table-strategy-ref in &lt;sharding:sharding-rule/&gt;</td>
</tr>

<tr>
<td>logic-index</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The Logic index name. If you want to use <em>DROP INDEX XXX</em> SQL in Oracle/PostgreSQL，This property needs to be set for finding the actual tables.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-binding-table-rules">&lt;sharding:binding-table-rules/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>binding-table-rule</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>The rule for binding tables.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-binding-table-rule">&lt;sharding:binding-table-rule/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>logic-tables</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The name of Logic tables, multiple tables are separated by commas.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-standard-strategy">&lt;sharding:standard-strategy/&gt;</h4>

<p>The standard sharding strategy for single sharding column.</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>sharding-column</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The name of sharding column.</td>
</tr>

<tr>
<td>precise-algorithm-class</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The class name for precise-sharding-algorithm used for = and IN. The default constructor or on-parametric constructor is needed.</td>
</tr>

<tr>
<td>range-algorithm-class</td>
<td>Property</td>
<td>String</td>
<td>N</td>
<td>The class name for range-sharding-algorithm used for BETWEEN. The default constructor or on-parametric constructor is needed.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-complex-strategy">&lt;sharding:complex-strategy/&gt;</h4>

<p>The complex sharding strategy for multiple sharding columns.</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>sharding-columns</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The name of sharding column. Multiple names separated with commas.</td>
</tr>

<tr>
<td>algorithm-class</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td># The class name for sharding-algorithm. The default constructor or on-parametric constructor is needed.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-inline-strategy">&lt;sharding:inline-strategy/&gt;</h4>

<p>The inline-expression sharding strategy.</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>sharding-column</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>the  name of sharding column.</td>
</tr>

<tr>
<td>algorithm-expression</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The expression for sharding algorithm.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-hint-database-strategy">&lt;sharding:hint-database-strategy/&gt;</h4>

<p>The Hint-method sharding strategy.</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>algorithm-class</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The class name for sharding-algorithm. The default constructor or on-parametric constructor is needed.</td>
</tr>
</tbody>
</table>

<h4 id="sharding-none-strategy">&lt;sharding:none-strategy/&gt;</h4>

<p>The none sharding strategy.</p>

<h4 id="sharding-props">&lt;sharding:props/&gt;</h4>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>sql.show</td>
<td>Property</td>
<td>boolean</td>
<td>Y</td>
<td>To show SQLS or not, the default is false.</td>
</tr>

<tr>
<td>executor.size</td>
<td>Property</td>
<td>int</td>
<td>N</td>
<td>The number of running threads.</td>
</tr>
</tbody>
</table>

<h4 id="master-slave-data-source">&lt;master-slave:data-source/&gt;</h4>

<p>Define datasorce for Reading-writing spliting.</p>

<table>
<thead>
<tr>
<th><em>Name</em></th>
<th><em>Type</em></th>
<th><em>DataType</em></th>
<th><em>Required</em></th>
<th><em>Info</em></th>
</tr>
</thead>

<tbody>
<tr>
<td>id</td>
<td>Property</td>
<td>String</td>
<td>Y</td>
<td>The spring Bean ID</td>
</tr>

<tr>
<td>master-data-source-name</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>The Bean ID of Master database.</td>
</tr>

<tr>
<td>slave-data-source-names</td>
<td>Label</td>
<td>-</td>
<td>Y</td>
<td>The list of Slave databases, multiple items are separated by commas.</td>
</tr>

<tr>
<td>strategy-ref?</td>
<td>Label</td>
<td>-</td>
<td>N</td>
<td>The Bean ID for complex strategy of Master-Slaves. User-defined complex strategy is allowed.</td>
</tr>

<tr>
<td>strategy-type?</td>
<td>Label</td>
<td>String</td>
<td>N</td>
<td>The complex strategy type of Master-Slaves. <br />The options: ROUND_ROBIN, RANDOM<br />. The default: ROUND_ROBIN</td>
</tr>
</tbody>
</table>

<h4 id="more-details-on-spring-configuration">More details on Spring Configuration</h4>

<p>To use inline expression, please configure <em>ignore-unresolvable</em> to be true, otherwise placeholder will treat the inline expression as an attribute key and then errors arises.</p>

<h2 id="the-description-of-sharding-algorithm-expression-syntax">The description of sharding algorithm expression syntax</h2>

<h3 id="the-details-on-inline-expression">The details on inline expression</h3>

<p>${begin..end} # indicate the number range.</p>

<p>${[unit1, unit2, unitX]} # indicate enumeration values</p>

<p>consecutive ${&hellip;} in inline expression # The Cartesian product among all the ${&hellip;} will be the final expression result, for example:</p>

<p>An inline expression:</p>

<pre><code class="language-groovy">dbtbl_${['online', 'offline']}_${1..3}
</code></pre>

<p>The final expression result:</p>

<p>dbtbl_online_1，dbtbl_online_2，dbtbl_online_3，dbtbl_offline_1，dbtbl_offline_2和dbtbl_offline_3.</p>

<h3 id="the-groovy-code-in-strings">The groovy code in strings</h3>

<p>By using ${}, we can embed groovy code in strings to generate the final expression, for example:</p>

<pre><code class="language-groovy">data_source_${id % 2 + 1}
</code></pre>

<p>data<em>source</em> is the prefix and id % 2 + 1 is groovy code in this example.</p>

<h2 id="4-spring-boot-configuration">4.Spring Boot Configuration</h2>

<h3 id="import-the-dependency-of-maven-3">Import the dependency of maven</h3>

<pre><code class="language-xml">&lt;dependency&gt;
    &lt;groupId&gt;io.shardingjdbc&lt;/groupId&gt;
    &lt;artifactId&gt;sharding-jdbc-core-spring-boot-starter&lt;/artifactId&gt;
    &lt;version&gt;${latest.release.version}&lt;/version&gt;
&lt;/dependency&gt;
</code></pre>

<h3 id="configuration-example-3">Configuration Example</h3>

<h4 id="sharding-configuration-2">Sharding Configuration</h4>

<pre><code class="language-yaml">sharding.jdbc.datasource.names=ds,ds_0,ds_1
sharding.jdbc.datasource.ds.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds.driverClassName=org.h2.Driver
sharding.jdbc.datasource.ds.url=jdbc:mysql://localhost:3306/ds
sharding.jdbc.datasource.ds.username=root
sharding.jdbc.datasource.ds.password=

sharding.jdbc.datasource.ds_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_0.driverClassName=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_0.url=jdbc:mysql://localhost:3306/ds_0
sharding.jdbc.datasource.ds_0.username=root
sharding.jdbc.datasource.ds_0.password=

sharding.jdbc.datasource.ds_1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_1.driverClassName=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_1.url=jdbc:mysql://localhost:3306/ds_1
sharding.jdbc.datasource.ds_1.username=root
sharding.jdbc.datasource.ds_1.password=

sharding.jdbc.config.sharding.default-data-source-name=ds
sharding.jdbc.config.sharding.default-database-strategy.inline.sharding-column=user_id
sharding.jdbc.config.sharding.default-database-strategy.inline.algorithm-inline-expression=ds_${user_id % 2}
sharding.jdbc.config.sharding.tables.t_order.actualDataNodes=ds_${0..1}.t_order_${0..1}
sharding.jdbc.config.sharding.tables.t_order.tableStrategy.inline.shardingColumn=order_id
sharding.jdbc.config.sharding.tables.t_order.tableStrategy.inline.algorithmInlineExpression=t_order_${order_id % 2}
sharding.jdbc.config.sharding.tables.t_order.keyGeneratorColumnName=order_id
sharding.jdbc.config.sharding.tables.t_order_item.actualDataNodes=ds_${0..1}.t_order_item_${0..1}
sharding.jdbc.config.sharding.tables.t_order_item.tableStrategy.inline.shardingColumn=order_id
sharding.jdbc.config.sharding.tables.t_order_item.tableStrategy.inline.algorithmInlineExpression=t_order_item_${order_id % 2}
sharding.jdbc.config.sharding.tables.t_order_item.keyGeneratorColumnName=order_item_id
</code></pre>

<h4 id="the-details-on-some-config-options-for-sharding">The details on some Config options for Sharding</h4>

<p>Refer to <a href="#The config items for Sharding">The Yaml Configuration for Sharding</a></p>

<h4 id="read-write-splitting-configuration-2">Read-write splitting Configuration</h4>

<pre><code class="language-yaml">sharding.jdbc.datasource.names=ds_master,ds_slave_0,ds_slave_1

sharding.jdbc.datasource.ds_master.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_master.driverClassName=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_master.url=jdbc:mysql://localhost:3306/demo_ds_master
sharding.jdbc.datasource.ds_master.username=root
sharding.jdbc.datasource.ds_master.password=

sharding.jdbc.datasource.ds_slave_0.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_slave_0.driverClassName=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_slave_0.url=jdbc:mysql://localhost:3306/demo_ds_slave_0
sharding.jdbc.datasource.ds_slave_0.username=root
sharding.jdbc.datasource.ds_slave_0.password=

sharding.jdbc.datasource.ds_slave_1.type=org.apache.commons.dbcp.BasicDataSource
sharding.jdbc.datasource.ds_slave_1.driverClassName=com.mysql.jdbc.Driver
sharding.jdbc.datasource.ds_slave_1.url=jdbc:mysql://localhost:3306/demo_ds_slave_1
sharding.jdbc.datasource.ds_slave_1.username=root
sharding.jdbc.datasource.ds_slave_1.password=

sharding.jdbc.config.masterslave.load-balance-algorithm-type=round_robin
sharding.jdbc.config.masterslave.name=ds_ms
sharding.jdbc.config.masterslave.master-data-source-name=ds_master
sharding.jdbc.config.masterslave.slave-data-source-names=ds_slave_0,ds_slave_1

</code></pre>

<h4 id="the-details-on-some-config-options-for-reading-writing-splitting">The details on some Config options for Reading-writing splitting</h4>

<p>Refer to <a href="#The config items for Read-write splitting">The Yaml configration for Reading-writing spliting</a></p>


      
      
      </div>
    </div>

    

    <div id="navigation">
        
        <a class="nav nav-prev" href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/master-slave/"> <i class="fa fa-chevron-left"></i></a>
        <a class="nav nav-next" href="http://shardingjdbc.io/document/legacy/2.x/en/02-guide/orchestration/" style="margin-right: 0px;"><i class="fa fa-chevron-right"></i></a>
    </div>

    </section>
    <div style="left: -1000px; overflow: scroll; position: absolute; top: -1000px; border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;">
      <div style="border: none; box-sizing: content-box; height: 200px; margin: 0px; padding: 0px; width: 200px;"></div>
    </div>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/clipboard.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/perfect-scrollbar.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/perfect-scrollbar.jquery.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/jquery.sticky-kit.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/featherlight.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/html5shiv-printshiv.min.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/highlight.pack.js"></script>
    <script>hljs.initHighlightingOnLoad();</script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/learn.js"></script>
    <script src="http://ovfotjrsi.bkt.clouddn.com/docs/js/hugo-learn.js"></script>
    <script src="http://cdn.bootcss.com/highlight.js/9.8.0/highlight.min.js"></script>
<script>hljs.initHighlightingOnLoad();</script>

  </body>
</html>

